package cn.bfay.lion.rest;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

import java.text.NumberFormat;

/**
 * LionRestApplication.
 *
 * @author wangjiannan
 */
@Slf4j
@SpringBootApplication
// 注册中心是eureka，那么就推荐@EnableEurekaClient，
// 如果是其他的注册中心，那么推荐使用@EnableDiscoveryClient.
@EnableEurekaClient
//@EnableDiscoveryClient
@EnableFeignClients
// @ServletComponentScan 注解后，Servlet、Filter、Listener 可以直接通过
// @WebServlet、@WebFilter、@WebListener 注解自动注册，无需其他代码
//@ServletComponentScan
// @EnableScheduling定时任务，多个任务并发（或需要在同一时间）执行时see {@link ScheduleConfig}
//@EnableScheduling
//@EnableTransactionManagement
@MapperScan("cn.bfay.lion.rest.mapper")
public class LionRestApplication {
    public static void main(String[] args) {
        SpringApplication.run(LionRestApplication.class, args);

        Runtime runtime = Runtime.getRuntime();
        final NumberFormat format = NumberFormat.getInstance();
        final long maxMemory = runtime.maxMemory();
        final long allocatedMemory = runtime.totalMemory();
        final long freeMemory = runtime.freeMemory();
        final long mb = 1024 * 1024;
        final String mega = "MB";
        log.info("========================== Memory Info ==========================");
        log.info("Free memory: " + format.format(freeMemory / mb) + mega);
        log.info("Allocated memory: " + format.format(allocatedMemory / mb) + mega);
        log.info("Max memory: " + format.format(maxMemory / mb) + mega);
        log.info("Total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / mb) + mega);
        log.info("=================================================================\n");
    }
}
